using DaoHang.Models;

namespace DaoHang.Services
{
    /// <summary>
    /// 用户服务接口，定义用户认证相关的业务操作
    /// </summary>
    public interface IUserService
    {
        /// <summary>
        /// 用户登录验证
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <returns>登录是否成功</returns>
        Task<bool> ValidateUserAsync(string username, string password);

        /// <summary>
        /// 根据用户名获取用户信息
        /// </summary>
        /// <param name="username">用户名</param>
        /// <returns>用户信息</returns>
        Task<User?> GetUserByUsernameAsync(string username);

        /// <summary>
        /// 创建默认管理员账户
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <param name="email">邮箱（可选）</param>
        /// <returns>创建的用户</returns>
        Task<User> CreateDefaultAdminAsync(string username, string password, string? email = null);

        /// <summary>
        /// 创建管理员账户（简化版本）
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <returns>创建的用户</returns>
        Task<User> CreateAdminUserAsync(string username, string password);

        /// <summary>
        /// 获取管理员用户
        /// </summary>
        /// <returns>管理员用户信息</returns>
        Task<User?> GetAdminUserAsync();

        /// <summary>
        /// 更新管理员用户信息
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <returns>是否更新成功</returns>
        Task<bool> UpdateAdminUserAsync(string username, string password);

        /// <summary>
        /// 检查是否存在管理员账户
        /// </summary>
        /// <returns>是否存在管理员</returns>
        Task<bool> HasAdminUserAsync();

        /// <summary>
        /// 密码哈希
        /// </summary>
        /// <param name="password">明文密码</param>
        /// <returns>哈希后的密码</returns>
        string HashPassword(string password);

        /// <summary>
        /// 验证密码
        /// </summary>
        /// <param name="password">明文密码</param>
        /// <param name="hash">哈希密码</param>
        /// <returns>密码是否正确</returns>
        bool VerifyPassword(string password, string hash);

        /// <summary>
        /// 获取所有用户列表（调试用）
        /// </summary>
        /// <returns>用户列表</returns>
        Task<IEnumerable<User>> GetAllUsersAsync();

        /// <summary>
        /// 修改用户密码
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="oldPassword">旧密码</param>
        /// <param name="newPassword">新密码</param>
        /// <returns>是否修改成功</returns>
        Task<bool> ChangePasswordAsync(string username, string oldPassword, string newPassword);

        /// <summary>
        /// 管理员重置用户密码
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="newPassword">新密码</param>
        /// <returns>是否重置成功</returns>
        Task<bool> ResetPasswordAsync(string username, string newPassword);
    }
} 